Sound Input Parameter Blocks
The
SPBRecord
and
SPBRecordToFile
functions require a pointer to a sound input parameter block that defines characteristics of the recording. If you define a sound input completion routine or a sound input interrupt routine, your routine receives a pointer to a sound input parameter block. If you are using only the Sound Input Manager's high-level
SndRecord
and
SndRecordToFile
functions, the operation of sound input parameter blocks is transparent to your application. A sound input parameter block is defined by the
SPB
data type.
TYPE SPB =
RECORD
inRefNum: LongInt; {reference number of input device}
count: LongInt; {number of bytes to record}
milliseconds: LongInt; {number of milliseconds to record}
bufferLength: LongInt; {length of buffer to record into}
bufferPtr: Ptr; {pointer to buffer to record into}
completionRoutine: ProcPtr; {pointer to a completion routine}
interruptRoutine: ProcPtr; {pointer to an interrupt routine}
userLong: LongInt; {for application's use}
error: OSErr; {error returned after recording}
unused1: LongInt; {reserved}
END;
-
inRefNum
-
The reference number of the sound input device (as received from the
SPBOpenDevice
function) from which the recording is to occur.
-
count
-
On input, the number of bytes to record. On output, the number of bytes actually recorded. If this field specifies a longer recording time than the
milliseconds
field, then the
milliseconds
field is ignored on input.
-
milliseconds
-
On input, the number of milliseconds to record. On output, the number of milliseconds actually recorded. If this field specifies a longer recording time than the
count
field, then the
count
field is ignored on input.
-
bufferLength
-
The length of the buffer into which recorded sound data is placed. The recording time specified by the
count
or
milliseconds
field is truncated to fit into this length, if necessary.
-
bufferPtr
-
A pointer to the buffer into which recorded data is placed. If this field is
NIL
, then the
count
,
milliseconds
, and
bufferLength
fields are ignored and the recording will continue indefinitely until the
SPBStopRecording
function is called. However, the data is not stored anywhere, so setting this field to
NIL
is useful only if you want to do something in a sound input interrupt routine but do not want to save the recorded sound.
-
completionRoutine
-
A pointer to a completion routine that is called when the recording terminates as a result of your calling the
SPBStopRecording
function or when the limit specified by the
count
or
milliseconds
field is reached. The completion routine executes only if
SPBRecord
is called asynchronously and therefore is called at interrupt time.
-
interruptRoutine
-
A pointer to a routine that is called by asynchronous recording devices when their internal buffers are full. You can define a sound input interrupt routine to modify uncompressed sound samples before they are placed into the buffer specified in the
bufferPtr
parameter. The interrupt routine executes only if
SPBRecord
is called asynchronously and therefore is called at interrupt time.
-
userLong
-
A long integer available for the application's own use. You can use this field, for instance, to pass a handle to an application-defined structure to the completion routine or to the interrupt routine.
-
error
-
On exit, the error that occurred during recording. This field contains a value greater than 0 while recording unless an error occurs, in which case it contains a value less than 0 that indicates an operating system error. Your application can poll this field to check on the status of an asynchronous recording. If recording terminates without an error, this field contains 0.
-
unused1
-
Reserved for use by Apple. You should always initialize this field to 0.
© 1998 Apple Computer, Inc.| Previous | Chapter contents | Chapter top | Section top | Next |